import random

# 随机数状态
# random.getstate() 返回一个元组，包含随机数生成器的当前内部状态
x = random.getstate()
print(x)
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)

# random.setstate() 可以恢复之前保存的状态
# 恢复状态后，随机数序列会从保存点开始完全重复
random.setstate(x)
print("\n重新设置随机数的状态之后\n")
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)
answer = random.randint(1, 10)
print(answer)